﻿using System;

namespace Microsoft.Popfly.GameCreator.GameEngine.Behaviors
{
    public class ReverseAndKillBehavior : IBehavior
    {
        private BehaviorOwner m_owner;
        private Events.EventListener m_listenerToKill;
        private MotionBehavior m_motionToReverse;

        public ReverseAndKillBehavior(BehaviorOwner owner, Events.EventListener listenerToKill, MotionBehavior motionToReverse)
        {
            m_owner = owner;
            m_listenerToKill = listenerToKill;
            m_motionToReverse = motionToReverse;
        }
        #region IBehavior Members

        public void Invoke(BehaviorOwner sender, Microsoft.Popfly.GameCreator.GameEngine.Events.PGCEventArgs args)
        {
            m_owner.RemoveBehavior(m_listenerToKill);
            m_motionToReverse.Reverse();
        }

        #endregion
    }
}
